package com.by.controller;

import com.by.bean.Quote;
import com.by.bean.ResultBean;
import com.by.service.QuoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * date 2025/3/4 15:50
 * author bjj
 * decoration
 * version 1.0
 * since jdk11
 */
@RestController
@Api(tags = "报价")
@RequestMapping("/api")
public class QuoteController extends BaseController {
    @Autowired
    QuoteService quoteService;


    @PostMapping("/quote/save")
    @ApiOperation("保存报价")
    public ResultBean save(@RequestBody Quote quote) {
        int rs = quoteService.save(quote);
        return saveResult(rs);
    }

    @PostMapping("/quote/update")
    @ApiOperation("修改报价")
    public ResultBean update(@RequestBody Quote quote) {
        int rs = quoteService.update(quote);
        return updateResult(rs);
    }

    @ApiOperation("根据询价编码查询报价信息")
    @GetMapping("/quote/getById")
    public ResultBean getById(@RequestParam String id){
        Quote quote = quoteService.getByRelationSn(id);
        if (quote == null){
            return fail("报价信息不存在");
        }
        return success("报价信息",quote);
    }
}
